home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_08
/
8n08068a
< prev
next >
Wrap
Text File
|
1990-07-17
|
735b
|
35 lines
my_qsort(int data[],int first,int last)
{
int i;
int j;
int temp;
i = first + 1;
j = last;
while ( i <= j )
{
while ( data[i] <= data[first] && i <= last )
i++;
while ( data[j] >= data[first] && j > first )
j--;
if ( j > i )
{
temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
temp = data[first];
data[first] = data[j];
data[j] = temp;
if ( (j-first) > 1 )
my_qsort( data, first, j-1 );
if ( (last-j) > 1 )
my_qsort( data, j+1, last );
}
A Minimal Quicksort Written in C
Figure 7